<!DOCTYPE html>
<html ng-app="app">
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style type="text/css">
			.username.ng-valid {
				background-color: green;
			}
			.username.ng-dirty.ng-invalid-required {
				background-color: red;
			}
			.username.ng-dirty.ng-invalid-minlength {
				background-color: lightpink;
			}
		</style>
	</head>
	<body ng-controller="controller as ctrl">
		<form ng-submit="ctrl.submit()" name="myForm">
			<input type="text" class="username" name="uname" ng-model="ctrl.user.username" required="required" ng-minlength="4" />
			<input type="submit" value="submit" ng-disabled="myForm.$invalid" />
		</form>
	</body>
	<script src="js/angular.min.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		angular.module('app', [])
		.controller('controller', [function(){
			var self = this;
			self.submit = function(){
				console.log(self.user);
			};
		}]);
	</script>
</html>
